﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Interfaces
{
    public enum PositionOriginator { Gps, Cell, Wifi, Bluetooth };

    /// <summary>
    /// Jelenleg adat a vezérlője az On... fgv-eknek
    /// </summary>
    public class PositionEventArgs : EventArgs
    {
        public IPositionData[] Position;

        public PositionEventArgs(IPositionData[] pos)
        {
            this.Position = pos;
        }
    }  

    public delegate void RequestedDataAvailableHandler(object sender, PositionEventArgs e);
    public delegate void NewSignalEventHandler(object sender, PositionEventArgs e);
    public delegate void BestSignalEventHandler(object sender, PositionEventArgs e);
    public delegate void RadioSwitchedOffEventHandler(object sender, EventArgs e);
    public delegate void RadioSwitchedOnEventHandler(object sender, EventArgs e);

    public interface IPositionOriginator : IModule
    {
        void OnNewSignal(PositionEventArgs e);
        void OnBestSignal(PositionEventArgs e);
        void OnRadioSwitchedOff(EventArgs e);
        void OnRadioSwitchedOn(EventArgs e);
        void OnRequestedDataAvailable(PositionEventArgs e);

        /// <summary>
        /// Get/Set the reference to the host application
        /// </summary>
        IPositionHandler Host { get; set; }

        /// <summary>
        /// Ezen keresztül lehet állítani, hogy a modulok milyen gyakran nézzenek új adatok után.
        /// </summary>
        int Rate { get; set; }

        /// <summary>
        /// Returns the type of the position originator (currently: Gps, Cell, Wifi or Bluetooth).
        /// </summary>
        /// <returns>The type of the module (enum PositionOriginator)</returns>
        PositionOriginator GetType();

        /// <summary>
        /// Returns the status of the radio interface.
        /// </summary>
        /// <returns>If the corresponding module is on, returns true, otherwise false</returns>
        bool GetRadioStatus();

        /// <summary>
        /// Turns on the module (in the case of GSM/UMTS module, starts the data collection)
        /// </summary>
        /// <returns>0, if the operation was successful, otherwise the error code</returns>
        int SetRadioOn();

        /// <summary>
        /// Turns off the module (in the case of GSM/UMTS module, starts the data collection)
        /// </summary>
        /// <returns>0, if the operation was successful, otherwise the error code</returns>
        int SetRadioOff();

        /// <summary>
        /// Turns on the module for the time given in the parameter (s), when the time is out, the module fires the RadioSwitchedOff event
        /// </summary>
        /// <returns>0, if the operation was successful, otherwise the error code</returns>
        int SetRadioOn(int interval);

        /// <summary>
        /// turns off the module for the time given in the parameter (s), when the time is out, the module fires the RadioSwitchedOn event
        /// </summary>
        /// <returns>0, if the operation was successful, otherwise the error code</returns>
        int SetRadioOff(int interval);

        /// <summary>
        /// Call on the module to collect data and fire the RequestedDataAvailable event, when it's done
        /// </summary>
        /// <returns>0, if the operation was successful, otherwise the error code</returns>
        int DataRequest();

        event RequestedDataAvailableHandler RequestedDataAvailable;
        event NewSignalEventHandler NewSignalEvent;
        event BestSignalEventHandler BestSignalEvent;
        event RadioSwitchedOffEventHandler RadioSwitchedOffEvent;
        event RadioSwitchedOnEventHandler RadioSwitchedOnEvent;
    }

    public interface IAbsoluteOriginator : IPositionOriginator
    {
        //Define the absolute positioning methods here
    }

    public interface IProximityOriginator : IPositionOriginator
    {

        /// <summary>
        /// Collects the hashes of the current context
        /// </summary>
        /// <returns>A string array that contains the hash values</returns>
        List<string> GetCurrentContextHashes();

        /// <summary>
        /// Collects the detailed position data from the module
        /// </summary>
        /// <returns>Array of provided data (IProximityData) by the context members</returns>
        List<IProximityData> GetCurrentContextMembers();

        //Define proximity methods here...
    }

    public interface IGPSOriginator : IAbsoluteOriginator
    {
        GPSData GetData();
    }

    public interface ICellOriginator : IProximityOriginator
    {
        CellData GetData();
    }

    public interface IWifiOriginator : IProximityOriginator
    {
        WifiData[] GetData();
    }

    public interface IBluetoothOriginator : IProximityOriginator
    {
        BluetoothData[] GetData();
    }
}
